package disjunction.collections
{
	/**
	 *
	 *
	 * @author Nick Wiggill
	 */
	
	public class CollectionReadWrite extends CollectionReadOnly
	{
		public function CollectionReadWrite(items:Array)
		{
			super(items);
		}
		
         /**
          * Adds a new item to the end of the Collection.
          *
          * @param item * to be added to the Collection. If item is Null it will not be added to the Collection.
          *
          * @return Boolean true if the Collection was changed as a result of the operation.
          */
        public function addItem(item:*):Boolean
        {
	            var result:Boolean = false;
	           
	            if (item != null)
	            {
		                _items.push(item);
		               
		                result = true;
	            }
	           
	            return result;
        }
       
         /**
          * Removes a single item from the Collection.  Returns false if item is not found.
          *
          * @param item reference to Collection item to be removed from Collection.
          *
          * @return Boolean true if item is found and successfully removed.  False if item is not found.
          */
        public function removeItem(item:*):Boolean
        {
	            var result:Boolean = false;
	            var itemIndex:int = internalGetItem(item);
	           
	            if (itemIndex> -1)
	            {
		                _items.splice(itemIndex, 1);
		               
		                result = true;
	            }
	           
	            return result;
        }
       
         /**
          * Removes all items from the Collection.
          *
          * @return Nothing
          */
        public function clear():void
        {
	            _items = new Array();
        }
	}
}